package org.bing.engine.core.domain;

import java.util.Date;

public class ContainerInstance extends AbstractEntity {
    public static final String INST_GUID_PREFIX = "engine.guid";
    private static final long serialVersionUID = 1978L;
    private Domain domain;
    private Controller controller;
    private Application application;
    private ContainerSetting setting;
    // dynamic information
    private String deployLocation;
    private String globalId;
    private int port;
    private Date startTime;
    private Date lastActivityTime;

    public ContainerInstance() {

    }

    public ContainerInstance(String guid) {
        this.globalId = guid;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(domain == null ? "null" : domain.getName()).append(" ");
        sb.append(controller == null ? "null" : controller.getAddress()).append(" ");
        sb.append(setting == null ? "null" : setting.getName()).append(" ");
        sb.append(globalId);
        return sb.toString();
    }

    public Domain getDomain() {
        return domain;
    }

    public void setDomain(Domain domain) {
        this.domain = domain;
    }

    public Controller getController() {
        return controller;
    }

    public void setController(Controller controller) {
        this.controller = controller;
    }

    public ContainerSetting getSetting() {
        return setting;
    }

    public void setSetting(ContainerSetting setting) {
        this.setting = setting;
    }

    public String getFullGlobalId() {
        return INST_GUID_PREFIX + "=" + globalId;
    }

    public String getGlobalId() {
        return globalId;
    }

    public void setGlobalId(String globalId) {
        this.globalId = globalId;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getLastActivityTime() {
        return lastActivityTime;
    }

    public void setLastActivityTime(Date lastActivityTime) {
        this.lastActivityTime = lastActivityTime;
    }

    public Application getApplication() {
        return application;
    }

    public void setApplication(Application application) {
        this.application = application;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getDeployLocation() {
        return deployLocation;
    }

    public void setDeployLocation(String deployDirectory) {
        this.deployLocation = deployDirectory;
    }

}
